/*
@hehung
2023-2-8
转载请注明出处，版权由@hehung所有
email: 1398660197@qq.com
wechat: hehung95
*/

#ifndef APP_FLASH_HEX_H_
#define APP_FLASH_HEX_H_

#include "hal_data.h"
#include "stdbool.h"


#define FLASH_CODE_AREA_START   (0x20000)      // Application area starting from Block 11
#define FLASH_CODE_AREA_END     (0x7FFFF)
#define FLASH_BLOCK_SIZE        (0x8000)        // 32k
#define FLASH_WRITE_SIZE        (128U)


typedef struct flash_write_cache {
    uint32_t start_address;
    uint32_t next_address;
    bool dirty;
    uint8_t write_block[FLASH_WRITE_SIZE];
} flash_write_cache_t;



extern uint32_t FlashHex_StartProgramming(void);
extern void write_flash(uint32_t addr, uint8_t * pData, uint32_t len);


#endif /* APP_FLASH_HEX_H_ */
